package com.woniu.springbootshiro.mapper;

import com.woniu.springbootshiro.pojo.Role;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

@Mapper
public interface RoleMapper extends tk.mybatis.mapper.common.Mapper<Role> {

    @Select("SELECT a.* FROM sys_role a,sys_user_role c WHERE a.role_id = c.role_id  AND c.user_id = #{userId}")
    @Results({
            @Result(column = "role_id",property = "roleId"),
            @Result(column = "role_name",property = "roleName"),
            @Result(column = "role_id",property = "permissionList",many = @Many(select = "com.woniu.springbootshiro.mapper.PermissionMapper.selectPermissionListByRoleId",fetchType = FetchType.EAGER))
    })
    List<Role> selectRoleListByUserId(@Param("userId")Long userId);
}
